package com.ruoyi.ljj.controller.system;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ljj.domain.GasoInfo;
import com.ruoyi.ljj.domain.Gasoline;
import com.ruoyi.ljj.service.IGasolineService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;


import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 加注Controller
 * 
 * @author ruoyi
 * @date 2022-07-14
 */
@RestController
@RequestMapping("/ljj/gasoline")
public class GasolineController extends BaseController
{
    @Autowired
    private IGasolineService gasolineService;

    /**
     * 查询加注列表
     */
    @PreAuthorize("@ss.hasPermi('ljj:gasoline:list')")
    @GetMapping("/list")
    public TableDataInfo list(Gasoline gasoline)
    {
        startPage();
        List<Gasoline> list = gasolineService.selectGasolineList(gasoline);
        return getDataTable(list);
    }

    /**
     * 导出加注列表
     */
    @PreAuthorize("@ss.hasPermi('ljj:gasoline:export')")
    @Log(title = "加注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Gasoline gasoline)
    {
        List<Gasoline> list = gasolineService.selectGasolineList(gasoline);
        ExcelUtil<Gasoline> util = new ExcelUtil<Gasoline>(Gasoline.class);
        util.exportExcel(response, list, "加注数据");
    }

    /**
     * 获取加注详细信息
     */
    @PreAuthorize("@ss.hasPermi('ljj:gasoline:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(gasolineService.selectGasolineById(id));
    }

    /**
     * 新增加注
     */
    @PreAuthorize("@ss.hasPermi('ljj:gasoline:add')")
    @Log(title = "加注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Gasoline gasoline)
    {
        return toAjax(gasolineService.insertGasoline(gasoline));
    }

    /**
     * 修改加注
     */
    @PreAuthorize("@ss.hasPermi('ljj:gasoline:edit')")
    @Log(title = "加注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Gasoline gasoline)
    {
        return toAjax(gasolineService.updateGasoline(gasoline));
    }

    /**
     * 删除加注
     */
    @PreAuthorize("@ss.hasPermi('ljj:gasoline:remove')")
    @Log(title = "加注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gasolineService.deleteGasolineByIds(ids));
    }

    @GetMapping("/getGasoInfo")
    public TableDataInfo gasoInfo(GasoInfo gasoInfo)
    {
        startPage();
        List<GasoInfo> gasoInfo1 = gasolineService.getGasoInfo(gasoInfo);
        return getDataTable(gasoInfo1);
    }
}
